Skip to content

feat: create global opencode.jsonc if no configs exist#26992

Merged
rekram1-node merged 4 commits into
devfrom
fix/global-config-schema-stub
May 12, 2026
Merged

feat: create global opencode.jsonc if no configs exist#26992
rekram1-node merged 4 commits into
devfrom
fix/global-config-schema-stub

Conversation

@rekram1-node
Copy link
Copy Markdown
Collaborator

Summary

  • Create a default global opencode.jsonc with the config schema when no global config exists.
  • Skip the write when config is explicitly routed through OPENCODE_CONFIG, OPENCODE_CONFIG_DIR, or OPENCODE_CONFIG_CONTENT.
  • Add regression coverage for schema stub creation and the OPENCODE_CONFIG_DIR opt-out.

Tests

  • bun test test/config/config.test.ts
  • bun test test/config/config.test.ts -t "global jsonc|OPENCODE_CONFIG_DIR is set"

Closes #4208

@rekram1-node rekram1-node changed the title Create global config schema stub feat: create global opencode.jsonc if no configs exist May 12, 2026
@rekram1-node
Copy link
Copy Markdown
Collaborator Author

/review

Comment thread packages/opencode/src/config/config.ts
// explicitly routes config through env-provided paths or content.
if (!Flag.OPENCODE_CONFIG && !Flag.OPENCODE_CONFIG_DIR && !Flag.OPENCODE_CONFIG_CONTENT) {
const file = globalConfigFile()
if (!existsSync(file)) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggestion: this check only considers config.json, opencode.json, and opencode.jsonc, so a user who still has the legacy global config file will get a new opencode.jsonc stub before the legacy migration runs. That leaves both the schema stub and migrated config.json even though a global config did exist. Consider checking path.join(Global.Path.config, "config") before seeding, or moving this after the legacy migration.

@rekram1-node rekram1-node merged commit 4875757 into dev May 12, 2026
10 checks passed
@rekram1-node rekram1-node deleted the fix/global-config-schema-stub branch May 12, 2026 04:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

No opencode.json file

1 participant